home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.9 KB | 185 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMemHlp.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMEMHLP_H
- #define FWMEMHLP_H
-
- #ifndef FWCOMMON_H
- #include "FWCommon.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- //========================================================================================
- // CLASS FW_CAcquireLockedSystemHandle
- //
- // A resource acquisition helper object for locking a system handle within a scope.
- //========================================================================================
-
- class FW_CAcquireLockedSystemHandle
- {
- public:
- FW_DECLARE_AUTO(FW_CAcquireLockedSystemHandle)
-
- FW_CAcquireLockedSystemHandle(FW_PlatformHandle aSystemHandle);
- ~FW_CAcquireLockedSystemHandle();
-
- void* GetPointer() const;
-
- private:
- FW_PlatformHandle fLockedSystemHandle;
- void* fLockedPointer;
-
- #ifdef FW_BUILD_MAC
- SignedByte fLockState;
- #endif
-
- private:
- FW_CAcquireLockedSystemHandle(const FW_CAcquireLockedSystemHandle& acquireObject);
- FW_CAcquireLockedSystemHandle& operator=(const FW_CAcquireLockedSystemHandle& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireLockedSystemHandle::GetPointer
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireLockedSystemHandle::GetPointer() const
- {
- return fLockedPointer;
- }
-
- //========================================================================================
- // CLASS FW_CAcquireTemporarySystemHandle
- //
- // A resource acquisition helper object for allocating and locking a system handle
- // within a scope. You can transfer ownership of the handle by calling OrphanPointer.
- //========================================================================================
-
- class FW_CAcquireTemporarySystemHandle
- {
- public:
- FW_DECLARE_AUTO(FW_CAcquireTemporarySystemHandle)
-
- FW_CAcquireTemporarySystemHandle(unsigned long size);
- ~FW_CAcquireTemporarySystemHandle();
-
- void* Resize(unsigned long newSize);
-
- FW_PlatformHandle Orphan();
- FW_Boolean IsOrphan() const;
-
- FW_PlatformHandle GetPlatformHandle() const;
- void* GetPointer() const;
-
- private:
- FW_PlatformHandle fTemporarySystemHandle;
- void* fMemoryPointer;
- FW_Boolean fFree; // If TRUE, the dtor will free the fMemory
-
- private:
- FW_CAcquireTemporarySystemHandle(const FW_CAcquireTemporarySystemHandle& acquireObject);
- FW_CAcquireTemporarySystemHandle& operator=(const FW_CAcquireTemporarySystemHandle& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::GetPointer
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireTemporarySystemHandle::GetPointer() const
- {
- return fMemoryPointer;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::GetPlatformHandle
- //----------------------------------------------------------------------------------------
-
- inline FW_PlatformHandle FW_CAcquireTemporarySystemHandle::GetPlatformHandle() const
- {
- return fTemporarySystemHandle;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporarySystemHandle::IsOrphan
- //----------------------------------------------------------------------------------------
-
- inline FW_Boolean FW_CAcquireTemporarySystemHandle::IsOrphan() const
- {
- return !fFree;
- }
-
- //========================================================================================
- // CLASS FW_CAcquireTemporaryMemory
- //
- // A resource acquisition helper object for allocating a temporary memory block.
- // You can transfer ownership of the handle by calling OrphanPointer.
- //========================================================================================
-
- class FW_CAcquireTemporaryMemory
- {
- public:
- FW_DECLARE_AUTO(FW_CAcquireTemporaryMemory)
-
- FW_CAcquireTemporaryMemory(unsigned long size);
- ~FW_CAcquireTemporaryMemory();
-
- void* GetPointer() const;
-
- void* OrphanPointer();
-
- private:
- void* fPointer;
-
- private:
- FW_CAcquireTemporaryMemory(const FW_CAcquireTemporaryMemory& acquireObject);
- FW_CAcquireTemporaryMemory& operator=(const FW_CAcquireTemporaryMemory& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireTemporaryMemory::GetPointer
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireTemporaryMemory::GetPointer() const
- {
- return fPointer;
- }
-
- #ifdef FW_BUILD_MAC
- //========================================================================================
- // CLASS FW_CMacAcquireMultiFinderHeapZone
- //
- // A resource acquisition helper object to set the current heap zone to be the multifinder
- // heap zone. This is very useful for example with QuickTime.
- //========================================================================================
-
- class FW_CMacAcquireMultiFinderHeapZone
- {
- public:
- FW_DECLARE_AUTO(FW_CMacAcquireMultiFinderHeapZone)
-
- FW_CMacAcquireMultiFinderHeapZone();
- ~FW_CMacAcquireMultiFinderHeapZone();
-
- private:
- THz fOldHeap;
-
- private:
- FW_CMacAcquireMultiFinderHeapZone(const FW_CMacAcquireMultiFinderHeapZone& acquireObject);
- FW_CMacAcquireMultiFinderHeapZone& operator=(const FW_CMacAcquireMultiFinderHeapZone& acquireObject);
- // Copy constructor and assignment operator not valid for this class.
- };
- #endif
-
- #endif
-